#include "up_goods.h"
#include "ui_up_goods.h"
#include "mainwindow.h"
#include "main.h"
#include <cstring>
#include <string>
up_goods::up_goods(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::up_goods)
{
    ui->setupUi(this);
}

up_goods::~up_goods()
{
    delete ui;
}

void up_goods::on_buttonBox_accepted()
{
    std::string good_name = ui->lineEdit->text().toStdString();
    std::string good_id = ui->lineEdit_2->text().toStdString();
    std::string stk = ui->lineEdit_3->text().toStdString();
    std::string sld = ui->lineEdit_4->text().toStdString();
    std::string prev_p = ui->lineEdit_5->text().toStdString();
    std::string disc = ui->lineEdit_6->text().toStdString();
    std::string now_p = ui->lineEdit_7->text().toStdString();
    goods_info *item;
    item = g_first;
    while(item->next){
        item = item->next;
    }
    item->next = new goods_info(good_name.c_str(), good_id.c_str(), std::stoi(stk),
                 std::stoi(sld), std::stod(prev_p), std::stod(now_p), std::stod(disc));
    item->next->next = NULL;

}
